package com.spzx.report.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

@Configuration
public class MyThreadPoolConfig {

    @Bean
    public ThreadPoolExecutor getThreadPoolExecutor(){
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(
                8*2,16*2,3, TimeUnit.SECONDS,new ArrayBlockingQueue<>(1600),
                Executors.defaultThreadFactory(),new ThreadPoolExecutor.AbortPolicy()
        );
        threadPoolExecutor.prestartAllCoreThreads();// 创建池的时候直接初始化线程数
        return threadPoolExecutor;

    }
}